import request from '@/config/axios'

export interface ProductSortVO {
  id: number
  name: string
  parentId: number
  sort: number
  price: number
  status: number
  createTime: Date
}

// 查询商品分类（精简)列表
export const getSimpleProductSortList = (): Promise<ProductSortVO[]> => {
  return request.get({ url: '/javainfo/product-sort/simple-list' })
}

// 查询商品分类列表
export const getProductSortList = (params: any) => {
  return request.get({ url: '/javainfo/product-sort/list', params })
}

// 查询商品分类分页
export const getProductSortPage = async (params: PageParam) => {
  return await request.get({ url: '/javainfo/product-sort/list', params })
}

// 查询商品分类详情
export const getProductSort = (id: number) => {
  return request.get({ url: '/javainfo/product-sort/get?id=' + id })
}

// 新增商品分类
export const createProductSort = (data: ProductSortVO) => {
  return request.post({ url: '/javainfo/product-sort/create', data })
}

// 修改商品分类
export const updateProductSort = (data: ProductSortVO) => {
  return request.put({ url: '/javainfo/product-sort/update', data })
}

// 删除商品分类
export const deleteProductSort = async (id: number) => {
  return await request.delete({ url: '/javainfo/product-sort/delete?id=' + id })
}

// 批量删除商品分类
export const deleteProductSortList = async (ids: number[]) => {
  return await request.delete({ url: '/javainfo/product-sort/delete-list', params: { ids: ids.join(',') } })
}

